//g++ linked_list_with_class.cpp -o linked_list_with_class -std=gnu++0x

#include <iostream>
#include <cstdio>
#include <climits>

class ContainerElement
{
	ContainerElement *pNext;
	int mData;
public:
	void SetData(int element);
	void SetNext(ContainerElement *pNxt);
	ContainerElement* GetNext();

	ContainerElement();
	~ContainerElement();
};

ContainerElement::ContainerElement()
{
	mData = INT_MIN;
	pNext = nullptr;
}

ContainerElement::~ContainerElement()
{
	mData = INT_MIN;
	pNext = nullptr;
}

void ContainerElement::SetData(int element)
{
	mData = element;
}

void ContainerElement::SetNext(ContainerElement *pNxt)
{
	pNext = pNxt;
}

ContainerElement* ContainerElement::GetNext()
{
	return pNext;
}

class Container
{
private:
	ContainerElement *pHead;
	ContainerElement *pTail;	
private:
	void SetHead(ContainerElement *pElement);
	void SetTail(ContainerElement *pElement);
	void InsertElementIfListIsEmpty(int element);
	ContainerElement* CreateElement(int element, ContainerElement *pNext);
	Container();
	~Container();
public:
	ContainerElement* GetTail();
	ContainerElement* GetHead();
	bool IsEmpty();
	void AddElementAtFront(int element);
	void AddElementToBack(int element);
	void AddElementAt(int pos, int element);
	void RemoveFromBack();
	void RemoveFromFront();
	void RemoveAt(int pos);
	void RemoveData(int element);
	ContainerElement* SortArray();
	ContainerElement* Find(int element);
	ContainerElement* EraseAll();
};

Container::Container()
{
	pHead = nullptr;
	pTail = nullptr;
}

Container::~Container()
{
	//Really destroy list items
	pHead = nullptr;
	pTail = nullptr;
}

ContainerElement* Container::GetHead()
{
	return pHead;
}

ContainerElement* Container::GetTail()
{
	return pTail;
}

void Container::SetHead(ContainerElement *pElement)
{
	pHead = pElement;
}
void Container::SetTail(ContainerElement *pElement)
{
	pTail = pElement;
}

bool Container::IsEmpty()
{
	if(GetHead() == nullptr)
		return true;
	return false;
}

ContainerElement* Container::CreateElement(int element, ContainerElement *pNext)
{
	ContainerElement *pElement = new ContainerElement;
	pElement->SetData(element);
	pElement->SetNext(pNext);
}

void Container::InsertElementIfListIsEmpty(int element)
{
	if(GetHead() == nullptr && GetTail() == nullptr){
		ContainerElement *pElement = CreateElement(element, nullptr);
		SetHead(pElement);
		SetTail(pElement);
	}
}

void Container::AddElementAtFront(int element)
{
	if(GetHead() == nullptr && GetTail() == nullptr){
		InsertElementIfListIsEmpty(element);
	}
	else{
		ContainerElement *pElement = CreateElement(element, GetHead());
		SetHead(pElement);
	}
}

void Container::AddElementToBack(int element)
{
	if(GetHead() == nullptr && GetTail() == nullptr){
		InsertElementIfListIsEmpty(element);
	}
	else{
		ContainerElement *pElement = CreateElement(element, nullptr);
		GetTail()->SetNext(pElement);
		SetTail(pElement);
	}
}

int main()
{
	return 0;
}
